from django.urls import path,re_path
from ..views import *
from ..views.ScheduleFunction import startSchedule

urlpatterns = [
    # 测试接口
    path('',IndexViews.test,name="myhome_test"),

    # 认证API
    path('api/admin/login',IndexViews.login,name="myhome_login"),
    path('api/admin/register',IndexViews.register,name="myhome_register"),
    path('api/admin/logout',IndexViews.logout,name="myhome_logout"),
    path('api/admin/unregister',IndexViews.unregister,name="myhome_unregister"),

    # 前台API
    # 一、个人中心
    path('api/home/about',HomeViews.userAbout,name="myhome_userAbout"),
    path('api/home/update', HomeViews.userUpdate,name="myhome_userUpdate"),
    path('api/home/update/password', HomeViews.updatePassword,name="myhome_updatePassword"),
    path('api/home/update/avatar', HomeViews.updateAvatar,name="myhome_updateAvatar"),

    # 二、每日通知
    path('api/home/notice/list', HomeViews.noticeList, name="myhome_noticeList"),

    # 三、选品商城
    path('api/home/shop/index', HomeViews.shopIndex, name="myhome_shopIndex"),
    path('api/home/shop/recommend', AdminViews.goodsRecommendSearch, name="myhome_shopRecommend"),
    path('api/home/shop/goods/info', HomeViews.shopGoodsInfo, name="myhome_shopGoodsInfo"),

    # 四、商品评论
    path('api/home/comment/add', HomeViews.commentAdd, name="myhome_commentAdd"),
    path('api/home/comment/update', HomeViews.commentUpdate, name="myhome_commentUpdate"),
    path('api/home/comment/delete', HomeViews.commentDelete, name="myhome_commentDelete"),

    # 五、购物车
    path('api/home/cart/list', HomeViews.cartList, name="myhome_cartList"),
    path('api/home/cart/add', HomeViews.cartAdd, name="myhome_cartAdd"),
    path('api/home/cart/update', HomeViews.cartUpdate, name="myhome_cartUpdate"),
    path('api/home/cart/delete', HomeViews.cartDelete, name="myhome_cartDelete"),
    path('api/home/cart/submit', HomeViews.cartSubmit, name="myhome_cartSubmit"),
    path('api/home/cart/coupon/list', HomeViews.cartCouponList, name="myhome_cartCouponList"),

    # 后台API
    # 一、用户相关
    path('api/admin/user/search', AdminViews.userSearch,name="myhome_userSearch"),
    path('api/admin/user/update', AdminViews.userUpdate,name="myhome_userUpdate"),

    # 二、商品相关
    path('api/admin/goods/search', AdminViews.goodsSearch,name="myhome_goodsSearch"),
    path('api/admin/goods/add', AdminViews.goodsAdd,name="myhome_goodsAdd"),
    path('api/admin/goods/update', AdminViews.goodsUpdate,name="myhome_goodsUpdate"),
    path('api/admin/goods/delete', AdminViews.goodsDelete,name="myhome_goodsDelete"),
    path('api/admin/goods/upload', AdminViews.goodsUpload,name="myhome_goodsUpload"),

    # 三、积分相关
    path('api/admin/credit/search', AdminViews.creditSearch, name="myhome_creditSearch"),
    path('api/admin/credit/send', AdminViews.creditSend, name="myhome_creditSend"),
    path('api/admin/credit/repeal', AdminViews.creditRepeal, name="myhome_creditRepeal"),

    # 四、优惠券相关
    path('api/admin/coupon/search', AdminViews.couponSearch, name="myhome_couponSearch"),
    path('api/admin/coupon/send', AdminViews.couponSend, name="myhome_couponSend"),
    path('api/admin/coupon/repeal', AdminViews.couponRepeal, name="myhome_couponRepeal"),

    # 五、通知相关
    path('api/admin/notice/search', AdminViews.noticeSearch, name="myhome_noticeSearch"),
    path('api/admin/notice/add', AdminViews.noticeAdd, name="myhome_noticeAdd"),
    path('api/admin/notice/update', AdminViews.noticeUpdate, name="myhome_noticeUpdate"),
    path('api/admin/notice/delete', AdminViews.noticeDelete, name="myhome_noticeDelete"),

    # 六、兑换相关
    path('api/admin/exchange/search', AdminViews.exchangeSearch, name="myhome_exchangeSearch"),
    path('api/admin/exchange/confirm', AdminViews.exchangeConfirm, name="myhome_exchangeConfirm"),
    path('api/admin/exchange/cancel', AdminViews.exchangeCancel, name="myhome_exchangeCancel"),
    path('api/admin/exchange/info', AdminViews.exchangeInfo, name="myhome_exchangeInfo"),

    # 七、商品推荐相关
    path('api/admin/goods/recommend/search', AdminViews.goodsRecommendSearch, name="myhome_goodsRecommendSearch"),
    path('api/admin/goods/recommend/add', AdminViews.goodsRecommendAdd, name="myhome_goodsRecommendAdd"),
    path('api/admin/goods/recommend/delete', AdminViews.goodsRecommendDelete, name="myhome_goodsRecommendDelete"),

]

# 启用任务
startSchedule()

